<template>
	<div class="TpReview">

		<v-defect v-if="defect" :defectdata="defectdata"></v-defect>
		<div class="TpReview-item" v-for="evitem,key in EvalUateListdata" :key="key">
			<div class="TpReview-item-left">
				<div class="tpil-img-box">
					<img class="tpil-img" v-if="baseInfodata.imgUrl!=''" :src="baseInfodata.imgUrl" />
					<img class="tpil-img" v-else src="../assets/img/images/zhudd-userimg_03.png" />
				</div>
			</div>
			<div class="TpReview-item-right">
				<div class="tprir-namebox">
					<span>{{baseInfodata.nick}}</span><img @click="reopenconfirm(evitem.evaluateId)" class="invisible-icon" src="../assets/img/images/Reviewyc_05.png" />
				</div>
				<div class="tprir-reviewbox">

					{{evitem.evaluateConten}}
					<yd-lightbox :num="evitem.evaluateImg.length">
						<yd-lightbox-img class="mylightboximg" v-for="item, key in evitem.evaluateImg" :key="key" :src="item.imgUrl"></yd-lightbox-img>
					</yd-lightbox>
					<p>{{evitem.createTime}}</p>
				</div>

				<div class="tprir-reviewbox" v-if="evitem.houseMasterConten!=''"><span class="landreview">房东回复:</span> {{evitem.houseMasterConten}}
					<p>{{evitem.houseMasterCreateTime}}</p>
				</div>
				<!--<div class="tprir-housebox">
					<div class="tprir-houseimg">
						<img src="../../dist/static/img/loginbg_02.bc48b07.jpg" />
					</div>
					<div class="tprir-houseright">
						<p>重庆解放碑温适阳光刚刚发 公寓夜景房重庆解放碑温适阳光刚刚发 公寓夜景房
						</p>
						<span>1500元/月</span>
					</div>
				</div>-->
			</div>
		</div>
	</div>
</template>

<script>
	import { mapGetters, mapActions } from 'vuex'
	import api from '../fetch/api'
	import defect from "./defect";
	export default {
		name: "TpReview",
		data() {
			return {
				getHiss: JSON.parse(sessionStorage.getItem("userinfo")),
				baseInfodata:JSON.parse(sessionStorage.getItem("baseInfodata")),
				defect:false,
				defectdata:{
					msg:'暂无评论',
					type:"TpReview"
				}
			}
		},
		computed: {
			...mapGetters([
				'source',
				'version',
				'EvalUateListdata',
			])
		},
		mounted() {
			this.EvalUateList();
		},
		methods: {
			...mapActions({
				getEvalUateList: "getEvalUateList"
			}),
			reopenconfirm(evaluateId) {
				let ajaxSign = {
					evaluateId: evaluateId.toString(),
					token: this.getHiss.token,
					source: this.source
				}
				this.$dialog.confirm({
					title: '确认隐藏评论？',
					mes: "隐藏后该评论在我的评论中不会出现，但会匿名出现在房源详情中",
					opts: () => {
						let ajaxData = api.getAES(ajaxSign);
						api.EditUserEvaluate(ajaxData)
							.then(res => {
								this.$dialog.toast({
									mes: res.msg,
									timeout: 1000
								});
								this.EvalUateList();
							})
					}
				});
			},
			EvalUateList() {
				let ajaxSign = {
					source: this.source, // string 是 请求源 ios
					type: '2', // string 是 = 1 房源全部评论， 2 用户个人评论， 3 房东所有评论 1
					token: this.getHiss.token, // string 否 type = 2 || type = 3 时必须携带 用户token
				}
				let ajaxData = api.getAES(ajaxSign);
				api.EvalUateList(ajaxData)
					.then(res => {
						if (res.result.length==0) {
							this.defect=true;
						}
						this.getEvalUateList(res.result);
					})

			}

		},
			components: {
				'v-defect': defect
			}

	}
</script>

<style>
	.tpil-img-box {
		width: .79rem;
		height: .79rem;
		border-radius: 50%;
		overflow: hidden;
	}
	
	.tpil-img {
		display: block;
		max-width: 100%;
		min-height: 100%;
		border-radius: 50%;
	}
	
	.TpReview-item {
		display: flex;
		padding: .24rem;
		box-sizing: border-box;
	}
	
	.TpReview-item-left {
		margin-right: .25rem;
	}
	
	.tprir-namebox {
		display: flex;
		justify-content: space-between;
		font-size: .31rem;
	}
	
	.invisible-icon {
		width: .44rem;
		height: .26rem;
	}
	
	.tprir-reviewbox {
		width: 5.98rem;
		word-break: break-all;
		/*只对英文起作用，以字母作为换行依据*/
		word-wrap: break-word;
		/*// 只对英文起作用，以单词作为换行依据*/
		color: #A4A4A4;
		font-size: .28rem;
		padding: .24rem 0;
		box-sizing: border-box;
	}
	
	.tprir-reviewbox p {
		text-align: right;
	}
	
	.landreview {
		color: #E25051;
		margin-right: .15rem;
	}
	
	.tprir-housebox {
		width: 5.4rem;
		height: 1.39rem;
		background: #f7f6f6;
		display: flex;
		padding: .06rem;
		box-sizing: border-box;
	}
	
	.tprir-houseimg {
		width: 2.3rem;
		height: 1.28rem;
		overflow: hidden;
		border-radius: .02rem;
		border: .2rem 1px #fff;
		margin-right: .24rem;
	}
	
	.tprir-houseimg img {
		display: block;
		width: 100%;
		height: 100%;
	}
	
	.tprir-houseright {
		width: 2.48rem;
	}
	
	.tprir-houseright p {
		font-size: .21rem;
		display: -webkit-box;
		-webkit-box-orient: vertical;
		-webkit-line-clamp: 2;
		overflow: hidden;
	}
	
	.tprir-houseright span {
		display: block;
		font-size: .26rem;
		color: #E25051;
		margin-top: .28rem;
	}
	
	.mylightboximg {
		width: 1.5rem;
		height: 1rem;
		margin: .24rem;
	}
</style>